<!doctype html>
{php}
    $static = '/static/home/';
{/php}
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>{$siteConfig['seo_title']}</title>
    <meta name="apple-mobile-web-app-title" content="{$siteConfig['seo_title']}">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="{$static}images/favicon.ico">
    <link href="{$static}css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="{$static}css/icons.min.css" rel="stylesheet" type="text/css" />
    <link href="{$static}css/app.min.css" rel="stylesheet" type="text/css" />
    <link href="{$static}css/style.css" rel="stylesheet" type="text/css" />
    <link href="{$static}libs/bootstrap-switch/css/bootstrap-switch.css" rel="stylesheet" type="text/css" />
</head>
<body data-sidebar="dark">
<div id="layout-wrapper">
    {include file='public/mine_topbar' /}
    {include file='public/mine_left' /}
    <div class="main-content">
        <div class="page-content">
            <div class="container-fluid">
                <!-- start page title -->
                <div class="row">
                    <div class="col-12">
                        <div class="page-title-box d-flex align-items-center justify-content-between">
                            <h4 class="mb-0 font-size-18"><i class="mdi mdi-laptop-chromebook"></i>批量添加配置渠道</h4>
                            <div class="page-title-right">
                                <ol class="breadcrumb m-0">
                                    <li class="breadcrumb-item"><a href="/">鹰眼短链</a></li>
                                    <li class="breadcrumb-item"><a href="{:url('urlChannel/index')}">我的渠道</a></li>
                                    <li class="breadcrumb-item active">批量添加渠道</li>
                                </ol>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- end page title -->

                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <form class="js-ajax-from" method="post">
                                    <p class="card-title-desc">配置主链接信息</p>
                                    <div class="row form-group">
                                        <label class="col-xl-2 col-md-6 col-form-label">主链短链接:</label>
                                        <div class="col-xl-6 col-md-6">
                                            <input type="text" class="form-control" value="{$domainUrl}/{$keyword}" disabled/>
                                            <input type="hidden" name="keyword" value="{$keyword}" >
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <label class="col-xl-2 col-md-6 col-form-label">主链原始链接:</label>
                                        <div class="col-xl-6 col-md-6">
                                            <input type="text" class="form-control" name="link"
                                                   placeholder="请输入您的原始链接，例如：https://a.com/?agentCode=100&channelCode=android">
                                            <em for="link" class="invalid"></em>
                                        </div>
                                    </div>
                                    <div class="dropdown-divider"></div>
                                    <p class="card-title-desc">配置批量生成渠道信息</p>
                                    <div class="row form-group">
                                        <label class="col-xl-2 col-md-6 col-form-label">渠道参数:</label>
                                        <div class="col-xl-6 col-md-6">
                                            <input class="form-control" id="params-switch" type="checkbox" checked>
                                            <input type="hidden" name="paramsSwitch" value="1">
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <label class="col-xl-2 col-md-6 col-form-label">生成渠道数量:</label>
                                        <div class="col-xl-6 col-md-6">
                                            <input type="text" class="form-control" name="channelNum" placeholder="请输入生成数量（整数）" />
                                            <em for="channelNum" class="invalid"></em>
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <label class="col-xl-2 col-md-6 col-form-label">渠道名称前缀:</label>
                                        <div class="col-xl-6 col-md-6">
                                            <input type="text" class="form-control" name="channelName" placeholder="请输入渠道名称前缀，例如：鹰眼" />
                                            <em for="channelName" class="invalid"></em>
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <label class="col-xl-2 col-md-6 col-form-label">渠道参数key:</label>
                                        <div class="col-xl-6 col-md-6">
                                            <input type="text" class="form-control" name="channelKey" value="channelCode" placeholder="请输入渠道参数，例如：aa" />
                                            <em for="channelKey" class="invalid"></em>
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <label class="col-xl-2 col-md-6 col-form-label">渠道参数value:</label>
                                        <div class="col-xl-6 col-md-6">
                                            <select class="form-control custom-select" name="channelCode">
                                                <option value='int'>随机8位数字</option>
                                                <option value='onlystr'>随机8位字母</option>
                                                <option value='str'>随机8位数字+字母</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <label class="col-xl-2 col-md-6 col-form-label">状态</label>
                                        <div class="col-xl-6 col-md-6">
                                            <select class="form-control custom-select" name="status">
                                                <option value='1'>启用</option>
                                                <option value='0'>禁用</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <label class="col-xl-2 col-md-6 col-form-label">备注:</label>
                                        <div class="col-xl-6 col-md-6">
                                            <textarea class="form-control" name="remark" rows="6" placeholder="例如：这个是推广渠道">{$info.remark}</textarea>
                                            <em for="remark" class="invalid"></em>
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <label class="col-xl-2 col-md-6 col-form-label"></label>
                                        <div class="col-xl-6 col-md-6">
                                            <input type="hidden" name="action" value="add" />
                                            <button type="submit" class="btn btn-primary btn-block waves-effect">
                                                <i class="mdi mdi mdi-folder-plus-outline"></i>
                                                <span>批量生成渠道</span>
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- end row -->

            </div> <!-- container-fluid -->
        </div>
        <!-- End Page-content -->

    </div>
    <!-- end main content-->

</div>
<!-- END layout-wrapper -->

<script src="{$static}libs/jquery/jquery.min.js"></script>
<script src="{$static}libs/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="{$static}libs/metismenu/metisMenu.min.js"></script>
<script src="{$static}libs/simplebar/simplebar.min.js"></script>
<script src="{$static}libs/node-waves/waves.min.js"></script>
<script src="{$static}libs/layer/layer.js"></script>

<script src="{$static}libs/bootstrap-switch/js/bootstrap-switch.js"></script>
<script src="{$static}js/pages/jquery.validate.min.js"></script>
<script src="{$static}js/app.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('#params-switch').bootstrapSwitch({
            onText : "显示",
            offText : "隐藏",
            onColor : "success",
            offColor : "danger",
            size : "normal",
            onSwitchChange : function(event, state) {
                var paramsSwitch = $('input[name=paramsSwitch]');
                if(state === true) {
                    paramsSwitch.val('1');
                }else {
                    paramsSwitch.val('0');
                }
            }
        });

        $(".js-ajax-from").validate({
            rules: {
                channelName: {
                    required: true,
                },
                channelCode: {
                    required: true,
                }
            },
            messages: {
                channelName: {
                    required: "请输入渠道名称",
                },
                channelCode: {
                    required: "请输入渠道码",
                }
            },
            submitHandler: function() {
                $.ajax({
                    url: "{:url('urlChannel/batchAddAjax')}",
                    type: "POST",
                    data: $(".js-ajax-from").serialize(),
                    dataType: 'json',
                    async: true,
                    success: function (res) {
                        if (res.errorCode === 200) {
                            window.location.href = "{:url('urlChannel/index')}";
                        } else {
                            layer.alert(res.message, {
                                title: '提示',
                                icon: 2
                            });
                        }
                    }
                });
            }
        });
    });
</script>
</body>
</html>